#ifndef CLOCK_H
#define CLOCK_H

#include <inttypes.h>

class Clock
{
public:
	Clock(uint8_t address);

	void begin();

	void beat();

	void set(uint8_t year, uint8_t month, uint8_t dayOfMonth, uint8_t hour, uint8_t minute, uint8_t second, uint8_t dayOfWeek);
	void get(uint8_t& year, uint8_t& month, uint8_t& hour, uint8_t& minute, uint8_t& second, uint8_t& dayOfWeek, uint8_t& dayOfMonth);

	uint8_t year() const;
	uint8_t month() const;
	uint8_t hour() const;
	uint8_t minute() const;
	uint8_t second() const;

	uint8_t dayOfWeek() const;
	uint8_t dayOfMonth() const;

	unsigned int now() const;

private:

	uint8_t bcdToDec(uint8_t val) const;
	uint8_t decToBcd(uint8_t val) const;

	uint8_t m_address;

	uint8_t m_year;
	uint8_t m_month;
	uint8_t m_hour;
	uint8_t m_minute;
	uint8_t m_second;

	uint8_t m_dayOfWeek;
	uint8_t m_dayOfMonth;
};

#endif
